import request from '@/axios';
import {baseUrl} from "@/config/env";

export const getList = (current, size, params) => {
  return request({
    url: baseUrl+'/ucs-system/service/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getEnterpriseStatusList = (eid) => {
    return request({
        url: baseUrl+'/ucs-system/serviceenterprise/listAllByEnterprise',
        method: 'get',
        params: {
            enterpriseId: eid
        }
    })
}

export const pageEnterpriseStatusList = (current, size, params) => {
    return request({
        url: baseUrl+'/ucs-system/serviceenterprise/pageAllByEnterprise',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}

export const orderService = (serviceId) => {
    return request({
        url: baseUrl+'/ucs-system/serviceenterprise/order',
        method: 'post',
        params:{
            serviceId: serviceId,
            orderType: 1
        }
    })
}

export const cancelService = (serviceId) => {
    return request({
        url: baseUrl+'/ucs-system/serviceenterprise/order',
        method: 'post',
        params:{
            serviceId: serviceId,
            orderType: -1
        }
    })
}

export const cancelServiceByEnterprise = (enterpriseId,serviceIds) => {
    return request({
        url: baseUrl+'/ucs-system/serviceenterprise/rejectService',
        method: 'post',
        params:{
            serviceId: serviceIds,
            enterpriseId:enterpriseId,
            orderType: -1
        }
    })
}

export const grantServiceTree = () => {
  return request({
    url: baseUrl+'/ucs-system/service/service-tree',
    method: 'get',
  })
}

export const getDetail = (id) => {
  return request({
    url: baseUrl+'/ucs-system/service/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: baseUrl+'/ucs-system/service/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const getServiceMenus = (serviceId) => {
  return request({
    url: baseUrl+'/ucs-system/service/service-tree-keys',
    method: 'get',
    params: {
      serviceId,
    }
  })
}

export const grant = (serviceId, menuIds) => {
  return request({
    url: baseUrl+'/ucs-system/service/grant',
    method: 'post',
    params: {
      serviceId,
      menuIds
    }
  })
}



export const add = (row) => {
  return request({
    url: baseUrl+'/ucs-system/service/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl+'/ucs-system/service/submit',
    method: 'post',
    data: row
  })
}

export const grantServiceMenuTree = () => {
    return request({
        url: baseUrl+'/ucs-system/menu/grantservicemenu-tree',
        method: 'get',
    })
}
